package form

import "github.com/pkg/errors"

type CategoryForm struct {
	Id   uint64 `form:"id"` // 主键
	Name string `form:"name"`
	Pid  uint   `form:pid"`
	Img  string `form:"img"` // 图片
}

// 进行参数合法性验证
func (this CategoryForm) Validate() (bool, error) {

	if len(this.Name) <= 1 || len(this.Name) > 20 {
		return false, errors.New("名称长度为1-20个字符")
	}

	return true, nil
}
